<script>
import { defineComponent, getCurrentInstance } from "vue";
import selectColor from "../selectColor.vue";

export default defineComponent({
  components: { selectColor },
  props: {
    that: Object,
  },
  setup(props) {
    return { that: props.that };
  },
  render() {
    let that = this.that;
    return (
      <a-collapse bordered={false}>
        <a-collapse-panel header="边框">
          <div class="styleValue">
            <span>颜色</span>
            {
              <selectColor
                color={this.$store.state.aimAttrs.color}
                onChange={(e) => {
                  this.$store.commit("aimAttrsChange", {
                    newValue: e,
                    attrsName: "borderColor",
                    that,
                  });
                  if (this.$store.state.aimAttrs.borderWidth == 0) {
                    this.$store.commit("aimAttrsChange", {
                      newValue: "1",
                      attrsName: "borderWidth",
                      that,
                    });
                  }
                }}
              />
            }
          </div>
          <div class="styleValue">
            <span>宽度</span>
            <a-input-number
              value={this.$store.state.aimAttrs.border.width}
              min={0}
              formatter={(value) => `${value}px`}
              parser={(value) => value.replace("p", "").replace("x", "")}
              style={{ width: "180px" }}
              onChange={(e) => {
                if (e == null) return;
                this.$store.commit("aimAttrsChange", {
                  newValue: e,
                  attrsName: "borderWidth",
                  that,
                });
              }}
            ></a-input-number>
          </div>
        </a-collapse-panel>
      </a-collapse>
    );
  },
});
</script>
